
using System.Reflection;
using System.Resources;

namespace Mistral
{
	public class ResourceUtils
	{
		public static ResourceManager GetResource( string partialResourceName, Assembly assembly )
		{
			ResourceManager manager = null;

			string resourceName = null;
			string[] names = assembly.GetManifestResourceNames();
			foreach ( string resourceFullName in names )
			{
				resourceName = resourceFullName.Substring( 0, resourceFullName.Length - ".resources".Length );
				if( resourceName.EndsWith( partialResourceName ) )
				{
					break;
				}
				resourceName = null;
			}
			if( resourceName != null )
				manager = new ResourceManager( resourceName, assembly );
			return manager;
		}
	}
}
